//初始化数据
// "tabBar": {
//   "list": [{
//     "pagePath": "pages/catchOrder/index",
//     "text": "接抢单",
//     "iconPath": "img/catch.png",
//     "selectedIconPath": "img/catchActive.png"
//   }, {
//     "pagePath": "pages/order/index",
//     "text": "工单",
//     "iconPath": "img/order.png",
//     "selectedIconPath": "img/orderActive.png"
//   }, {
//     "pagePath": "pages/mine/index",
//     "text": "我的",
//     "iconPath": "img/mine.png",
//     "selectedIconPath": "img/mineActive.png"
//   }],
//   "color": "#b1b1b1",
//   "selectedColor": "#F18C28",
//   "backgroundColor": "#fff",
//   "borderStyle": "white"
// }
function tabbarinit() {
  return [{
      "current": 0,
      "pagePath": "/pages/catchOrder/index",
      "iconPath": "../../img/catch.png",
      "selectedIconPath": "../../img/catchActive.png",
      "text": "接抢单"
    },
    {
      "current": 0,
      "pagePath": "/pages/order/index",
      "text": "工单",
      "iconPath": "../../img/order.png",
      "selectedIconPath": "../../img/orderActive.png"
    },
    {
      "current": 0,
      "pagePath": "/pages/mine/index",
      "text": "我的",
      "iconPath": "../../img/mine.png",
      "selectedIconPath": "../../img/mineActive.png"

    }
  ]

}
//tabbar 主入口
function tabbarmain(bindName = "tabdata", id, target, hideIndex) {
  var isiPhoneX = false
  wx.getSystemInfo({
    success: res => {
      isiPhoneX = res.model == 'iPhone X'
    }
  })
  var that = target;
  var bindData = {
    isX: isiPhoneX
  };
  if (hideIndex != undefined && hideIndex != null) {
    let arr = tabbarinit()
    arr.splice(hideIndex, 1)
    var otabbar = arr
  } else {
    var otabbar = tabbarinit();
  }
  otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath'] //换当前的icon
  otabbar[id]['current'] = 1;
  bindData[bindName] = otabbar
  that.setData({
    bindData
  });
}

module.exports = {
  tabbar: tabbarmain
}